home *** CD-ROM | disk | FTP | other *** search
/ Programming Windows 95 with MFC / Programming Windows 95 with MFC (Microsoft Programming Series)(097-0001465)(1996).iso / NT / CODE / CHAP12 / VISTA / MAINFRAME.CPP next >
Encoding:
C/C++ Source or Header  |  1996-04-05  |  1.6 KB  |  67 lines

  1. //***********************************************************************
  2. //
  3. //  MainFrame.cpp
  4. //
  5. //***********************************************************************
  6.  
  7. #include <afxwin.h>
  8. #include <afxext.h>
  9. #include "MainFrame.h"
  10.  
  11. IMPLEMENT_DYNCREATE (CMainFrame, CFrameWnd)
  12.  
  13. BEGIN_MESSAGE_MAP (CMainFrame, CFrameWnd)
  14.     ON_WM_CREATE ()
  15.     ON_MESSAGE (WM_USER, OnUpdateImageStats)
  16.     ON_WM_QUERYNEWPALETTE ()
  17.     ON_WM_PALETTECHANGED ()
  18. END_MESSAGE_MAP ()
  19.  
  20. int CMainFrame::OnCreate (LPCREATESTRUCT lpcs)
  21. {
  22.     static UINT nIndicators[] = {
  23.         ID_SEPARATOR,
  24.         ID_SEPARATOR,
  25.     };
  26.  
  27.     if (CFrameWnd::OnCreate (lpcs) == -1)
  28.         return -1;
  29.  
  30.     if (!m_wndStatusBar.Create (this))
  31.         return -1;
  32.  
  33.     m_wndStatusBar.SetIndicators (nIndicators, 2);
  34.  
  35.     TEXTMETRIC tm;
  36.     CClientDC dc (this);
  37.     CFont* pFont = m_wndStatusBar.GetFont ();
  38.     CFont* pOldFont = dc.SelectObject (pFont);
  39.     dc.GetTextMetrics (&tm);
  40.     dc.SelectObject (pOldFont);
  41.  
  42.     int cxWidth;
  43.     UINT nID, nStyle;
  44.     m_wndStatusBar.GetPaneInfo (1, nID, nStyle, cxWidth);
  45.     cxWidth = tm.tmAveCharWidth * 24;
  46.     m_wndStatusBar.SetPaneInfo (1, nID, nStyle, cxWidth);
  47.     return 0;
  48. }
  49.  
  50. LONG CMainFrame::OnUpdateImageStats (UINT wParam, LONG lParam)
  51. {
  52.     m_wndStatusBar.SetPaneText (1, (LPCTSTR) lParam, TRUE);
  53.     return 0;
  54. }
  55.  
  56. BOOL CMainFrame::OnQueryNewPalette ()
  57. {
  58.     GetActiveView ()->Invalidate (FALSE);
  59.     return TRUE;
  60. }
  61.  
  62. void CMainFrame::OnPaletteChanged (CWnd* pFocusWnd)
  63. {
  64.     if (pFocusWnd != this)
  65.         GetActiveView ()->Invalidate (FALSE);
  66. }
  67.